home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / round.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  333b  |  19 lines

  1. /* round rounds a floating point value to an integer value. */
  2.  
  3. #include "plplot.h"
  4. #include <math.h>
  5.  
  6. int round(flt)
  7. float flt;
  8. {
  9.     double mant, frac;
  10.  
  11.     frac = modf(flt,&mant);
  12.     if( fabs(frac) < .5 )
  13.         return((int)mant);
  14.     else if (frac > 0)
  15.         return((int)(++mant));
  16.     else 
  17.         return((int)(--mant));
  18. }
  19.